/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */

#ifndef __BOARD_CONFIG_H__
#define __BOARD_CONFIG_H__

#include <pin_name.h>

#ifdef __cplusplus
extern "C" {
#endif

/* console */
#define CONSOLE_TXD PA19
#define CONSOLE_RXD PA20
#define CONSOLE_TXD_FUNC PA19_UART1_TX
#define CONSOLE_RXD_FUNC PA20_UART1_RX
#define CONSOLE_IDX 1

/* wifi*/
#define WIFI_SDIO_CMD PA15
#define WIFI_SDIO_CMD_FUNC PA15_SDIO_CMD
#define WIFI_SDIO_CLK PA16
#define WIFI_SDIO_CLK_FUNC PA16_SDIO_CLK
#define WIFI_SDIO_DAT0 PA17
#define WIFI_SDIO_DAT0_FUNC PA17_SDIO_DAT0
#define WIFI_SDIO_DAT1 PA18
#define WIFI_SDIO_DAT1_FUNC PA18_SDIO_DAT1
#define WIFI_SDIO_DAT2 PA13
#define WIFI_SDIO_DAT2_FUNC PA13_SDIO_DAT2
#define WIFI_SDIO_DAT3 PA14
#define WIFI_SDIO_DAT3_FUNC PA14_SDIO_DAT3
#define WLAN_ENABLE_PIN PB2
#define WLAN_POWER_PIN 0xFFFFFFFF

/* BT */
#define BT_UART_IDX 0
#define BT_UART_TXD PA2
#define BT_UART_RXD PA0
#define BT_UART_TXD_FUNC PA2_UART0_TX
#define BT_UART_RXD_FUNC PA0_UART0_RX
#define BT_DIS_PIN PB4

/* button */
#define APP_KEY_MUTE PA29
#define APP_KEY_VOL_INC PB20
#define APP_KEY_VOL_DEC PA24
#define APP_KEY_STANDBY PA25

/* PA */
#define PIN_PA_MUTE PA23

/* LED */
#define LED0_PIN PB21
#define LED1_PIN PB31
#define LED_FLIP_FLAG 1 /* 低电平亮 */

/* I2C dot screen */
// #define USI0_SCLK PA21
// #define USI0_SCLK_FUNC PA21_USI0_SCLK
// #define USI0_SD0 PA22
// #define USI0_SD0_FUNC PA22_USI0_SD0
// #define USI0_IDX 0

#if defined(CONFIG_LCD_ILI9488) && CONFIG_LCD_ILI9488
/* LCD screen */
#define USI2_SPI_SCLK PB28
#define USI2_SPI_SCLK_FUNC PB28_USI2_SCLK
#define USI2_SPI_MOSI PB29
#define USI2_SPI_MOSI_FUNC PB29_USI2_SD0
#define USI2_SPI_MISO PB30
#define USI2_SPI_MISO_FUNC PB30_USI2_SD1
#define USI_SPI_IDX 2
#define SPI_CS PB27
#define SPI_RS PB26
#define SPI_RESET PB23
#endif

/* QSPI FLash */
#define EXAMPLE_QSPI_IDX 0

/* RTC */
#define CONFIG_RTC_EN 1
#define CONFIG_RTC_CLK (24540) /* internal RC CLK: 24.540KHz */

/* 可用GPIO列表 */
#define USER_GPIO_LIST_STR                                                                         \
    "GPIO ID  Name\n \
 21       PA21 (IIC_SCLK)\n \
 22       PA22 (IIC_SD0)\n \
 23       PA23 (-PA MUTE)\n \
 24       PA24 (-KEY K5)\n \
 25       PA25 (-KEY K6)\n \
 29       PA29 (-KEY K4)\n \
 32       PB0  (UART3_TX)\n \
 33       PB1  (UART3_RX)\n \
 52       PB20 (-KEY K3)\n \
 53       PB21 (-LED0)\n \
 54       PB22 (PWM1_O5/PWM_LED_DEMO)\n \
 55       PB23 (PWM1_O7/LCD_RESET)\n \
 56       PB24 (PWM1_O9/UART2_TX)\n \
 57       PB25 (PWM1_O11/UART2_RX)\n \
 58       PB26 (PWM1_IO0/LCD_RS)\n \
 59       PB27 (PWM1_IO2/LCD_CS)\n \
 60       PB28 (PWM1_IO4/SPI_SCK/LCD_SCL)\n \
 61       PB29 (PWM1_IO6/SPI_MOSI/LCD_SDA)\n \
 62       PB30 (PWM1_IO8/SPI_MISO)\n \
 63       PB31 (-LED1)\n \
"
#ifdef __cplusplus
}
#endif

#endif /* __BOARD_CONFIG_H__ */
